home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / General / Appsprites / USER CODE / Application.c next >
Text File  |  1993-07-08  |  3KB  |  197 lines

  1. ///--------------------------------------------------------------------------------------
  2. //    Application.c
  3. //
  4. //    Created:    Sunday, April 11, 1993
  5. //    By:        Tony Myles
  6. //
  7. //    Copyright: © 1993 Tony Myles, All rights reserved worldwide.
  8. ///--------------------------------------------------------------------------------------
  9.  
  10.  
  11. #if THINK_C
  12. #ifndef __BDC__
  13. #include <BDC.h>
  14. #endif
  15. #else
  16. #ifndef __PACKAGES__
  17. #include <Packages.h>
  18. #endif
  19. #endif
  20.  
  21. #ifndef __APPLEEVENTS__
  22. #include <AppleEvents.h>
  23. #endif
  24.  
  25. #ifndef __DESK__
  26. #include <Desk.h>
  27. #endif
  28.  
  29. #ifndef __DIALOGS__
  30. #include <Dialogs.h>
  31. #endif
  32.  
  33. #ifndef __DISKINIT__
  34. #include <DiskInit.h>
  35. #endif
  36.  
  37. #ifndef __EPPC__
  38. #include <EPPC.h>
  39. #endif
  40.  
  41. #ifndef __EVENTS__
  42. #include <Events.h>
  43. #endif
  44.  
  45. #ifndef __ERRORS__
  46. #include <Errors.h>
  47. #endif
  48.  
  49. #ifndef __FONTS__
  50. #include <Fonts.h>
  51. #endif
  52.  
  53. #ifndef __GESTALTEQU__
  54. #include <GestaltEqu.h>
  55. #endif
  56.  
  57. #ifndef __MENUS__
  58. #include <Menus.h>
  59. #endif
  60.  
  61. #ifndef __RESOURCES__
  62. #include <Resources.h>
  63. #endif
  64.  
  65. #ifndef __OSEVENTS__
  66. #include <OSEvents.h>
  67. #endif
  68.  
  69. #ifndef __TEXTEDIT__
  70. #include <TextEdit.h>
  71. #endif
  72.  
  73. #ifndef __TRAPS__
  74. #include <Traps.h>
  75. #endif
  76.  
  77. #ifndef __TOOLUTILS__
  78. #include <ToolUtils.h>
  79. #endif
  80.  
  81. #ifndef __WINDOWS__
  82. #include <Windows.h>
  83. #endif
  84.  
  85. #ifndef __SPRITEWORLDUTILS__
  86. #include <SpriteWorldUtils.h>
  87. #endif
  88.  
  89. #ifndef __APPLICATION__
  90. #include "Application.h"
  91. #endif
  92.  
  93. #include "Simple.h"
  94.  
  95.  
  96. WindowPtr gWindowP = NULL;
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103. void InitializeMasters(short numberOfMasters)
  104. {
  105.  
  106.     while (numberOfMasters--)
  107.     {
  108.         MoreMasters();
  109.     }
  110.  
  111. }
  112.  
  113.  
  114. Boolean CheckSystem(void)
  115. {
  116.     OSErr    err;
  117.     Boolean isSystemGood = true;
  118.     long    gestaltResult;
  119.  
  120.     err = Gestalt(gestaltTimeMgrVersion, &gestaltResult);
  121.  
  122.     isSystemGood = (err == noErr) && (gestaltResult >= gestaltStandardTimeMgr);
  123.  
  124.     if (!isSystemGood)
  125.     {
  126.         CantRunOnThisMachine();
  127.     }
  128.  
  129.     return isSystemGood;
  130. }
  131.  
  132.  
  133. void CreateWindow(void)
  134. {
  135.     gWindowP = SWHasColorQuickDraw() ?
  136.             GetNewCWindow(kWindowResID, NULL, (WindowPtr)-1L) :
  137.             GetNewWindow(kWindowResID, NULL, (WindowPtr)-1L);
  138.  
  139.     if (gWindowP == NULL)
  140.     {
  141.         CantFindResource();
  142.     }
  143. }
  144.  
  145.  
  146. void ErrorAlert(OSErr err, short errorStringIndex)
  147. {
  148.     Str255 messageString, errorString;
  149.  
  150.     GetIndString(messageString, kErrorStringListResID, errorStringIndex);
  151.  
  152.     if (messageString[0] == 0)
  153.     {
  154.         BlockMove(kSeriousDamageString, messageString, sizeof(kSeriousDamageString));
  155.     }
  156.  
  157.     NumToString(err, errorString);
  158.  
  159.     ParamText(messageString, errorString, "\p", "\p");
  160.  
  161.     (void)StopAlert(kErrorAlertResID, NULL);
  162. }
  163.  
  164.  
  165. void FatalError(OSErr err)
  166. {
  167.     if (err != noErr)
  168.     {
  169.         ErrorAlert(err, kFatalErrorStringIndex);
  170.  
  171.         ExitToShell();
  172.     }
  173. }
  174.  
  175.  
  176. void CantFindResource(void)
  177. {
  178.     OSErr err;
  179.  
  180.     err = ResError();
  181.  
  182.     if (err == noErr)
  183.     {
  184.         err = resNotFound;
  185.     }
  186.  
  187.     ErrorAlert(err, kCantFindResourceStringIndex);
  188.  
  189.     ExitToShell();
  190. }
  191.  
  192.  
  193. void CantRunOnThisMachine(void)
  194. {
  195.     (void)StopAlert(kCantRunAlertResID, NULL);
  196. }
  197.